﻿<!--
 Copyright © 2013 Nokia Corporation. All rights reserved.
 Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. 
 Other product and company names mentioned herein may be trademarks
 or trade names of their respective owners. 
 See LICENSE.TXT for license information.
-->

<phone:PhoneApplicationPage
    x:Class="MagnifierApp.Pages.PhotosPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="False">

    <!--Toolkit page transititions-->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush ImageSource="/Assets/ApplicationBackground.png"/>
        </Grid.Background>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{Binding Path=LocalizedResources.App_Title_Text, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{Binding Path=LocalizedResources.PhotosPage_Title_Text, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ScrollViewer x:Name="PhotosPanel" Margin="12,0,2,0" Visibility="Collapsed">
                <ItemsControl ItemsSource="{Binding Photos}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel ItemWidth="146" ItemHeight="146"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Thumbnail}" Margin="0,0,8,8" Tap="Thumbnail_Tap"
                                   CacheMode="BitmapCache" Tag="{Binding Tag}">
                                <toolkit:ContextMenuService.ContextMenu>
                                    <toolkit:ContextMenu Opened="ContextMenu_Opened" Closed="ContextMenu_Closed">
                                        <toolkit:MenuItem Header="{Binding Path=LocalizedResources.PhotosPage_ShareMenuItem_Text, Source={StaticResource LocalizedStrings}}"
                                                          Click="Share_Click" CommandParameter="{Binding Tag}"/>
                                        <toolkit:MenuItem Header="{Binding Path=LocalizedResources.PhotosPage_DeleteMenuItem_Text, Source={StaticResource LocalizedStrings}}"
                                                          Click="Delete_Click" CommandParameter="{Binding Tag}"/>
                                    </toolkit:ContextMenu>
                                </toolkit:ContextMenuService.ContextMenu>
                            </Image>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>

            <StackPanel x:Name="GuidePanel" Visibility="Collapsed">
                <TextBlock Text="{Binding Path=LocalizedResources.PhotosPage_GuideTextBlock_Text, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"
                           TextWrapping="Wrap" Margin="12,0,12,0"/>
            </StackPanel>
        </Grid>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar Opacity="0.5"
                              ForegroundColor="{StaticResource MagnifierAppApplicationBarForegroundColor}"
                              BackgroundColor="{StaticResource MagnifierAppApplicationBarBackgroundColor}">
            <!-- populated from code -->
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>